VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "BCLMark"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'*******************************************************************
'  Copyright (C) 2011 Intergraph Corporation  All rights reserved.
'
'  Project  : StrMfgTemplateMarkingEdge
'
'  Abstract : Create Base control line mark on unfolded Edge Template
'
'  History  :
'      Siva   20th April 2012    created
'
'******************************************************************
Option Explicit
Private Const MODULE = "StrMfgTemplateMarkingEdge.BCLMark"

Implements IJMfgTemplateMarkingRule

Private Function IJMfgTemplateMarkingRule_CreateMarks(ByVal oMfgTemplate As IJMfgTemplate, ByVal oReferenceObjColl As IJElements) As IJElements
Const METHOD = "IJMfgTemplateMarkingRule_CreateMarks"
On Error GoTo ErrorHandler
    
    Dim oBottomCurve2D  As IJCurve
    
    ' Get the reference objects like 2D bottom curve and top curve and ref curve used for unfold
    Dim iIndex  As Long
    For iIndex = 1 To oReferenceObjColl.Count
        Dim oTempObj    As Object
        Set oTempObj = oReferenceObjColl.Item(iIndex)
        
        If TypeOf oTempObj Is IJMfgGeom2d Then
            Dim oTempGeom2d As IJMfgGeom2d
            Set oTempGeom2d = oTempObj
            
            If oTempGeom2d.GetGeometryType = STRMFG_TemplateLocationMarkLine Then
                Set oBottomCurve2D = oTempGeom2d.GetGeometry
                Exit For
            End If
        End If
    Next
    
    ' Exit when inputs are not available
    If oBottomCurve2D Is Nothing Then
        Exit Function
    End If
    
    Dim oMfgRuleHelper As New MfgRuleHelpers.Helper
    
    '*** Get the wirebody from complexstring ***'
    Dim oBottomWB As IJWireBody
    Set oBottomWB = oMfgRuleHelper.ComplexStringToWireBody(oBottomCurve2D)

    '*** Get the middle point of the curve ***'
    Dim oMidPos As IJDPosition
    Set oMidPos = oMfgRuleHelper.GetMiddlePoint(oBottomWB)
        
    ' Get the curve normal
    Dim dTanX As Double, dTanY As Double, dTanZ As Double, dPar As Double, dDummy As Double
    
    oBottomCurve2D.Parameter oMidPos.x, oMidPos.y, oMidPos.z, dPar
    oBottomCurve2D.Evaluate dPar, dDummy, dDummy, dDummy, dDummy, dDummy, dDummy, dTanX, dTanY, dTanZ
    
    Dim oMarkVec    As IJDVector
    Set oMarkVec = New DVector
    
    oMarkVec.Set dTanX, dTanY, dTanZ
    
    ' Create BCL mark of fixed length
    Dim oBCLMark    As IJCurve
    Set oBCLMark = CreateLineAtPosition(oMidPos, oMarkVec, TEMPLATE_BCL_MARK_LENGTH, True)
    
    Dim oTempElems      As IJElements
    Set oTempElems = New JObjectCollection
    
    ' Create Geom2D for BCL mark
    Dim oMfgGeom2D As IJMfgGeom2d
    Set oMfgGeom2D = CreateGeom2D(oBCLMark, STRMFG_BASELINE_MARK, Nothing, "Base Control Mark")
    
    oTempElems.Add oMfgGeom2D
    
    Set IJMfgTemplateMarkingRule_CreateMarks = oTempElems
    Exit Function

ErrorHandler:
   Err.Raise StrMfgLogError(Err, MODULE, METHOD, , "SMCustomWarningMessages", 3016, , "RULES")
End Function
